#include <stdio.h>
#include <stdlib.h>

//https://www.nowcoder.com/practice/f2952ee3bb5c48a9be6c261e29dd1092?tpId=290&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D290

typedef struct Flexible {
    int N;
    int Mat[0];
}Flexible;

int main() {
    int row = 0;
    int col = 0;
    int count = 0;
    scanf("%d%d", &row, &col);
    Flexible *arr1 = (Flexible *) malloc(sizeof(Flexible) + row * col * sizeof(int));
    if (arr1 == NULL) {
        perror("堆区开辟空间失败:");
    }
    arr1->N = row * col;
    Flexible *arr2 = (Flexible *) malloc(sizeof(Flexible) + row * col * sizeof(int));
    if (arr2 == NULL) {
        perror("堆区开辟空间失败:");
    }
    arr2->N = row * col;
    for (int i = 0; i < arr1->N; i++) {
        scanf("%d", &arr1->Mat[i]);
    }
    for (int i = 0; i < arr2->N; i++) {
        scanf("%d", &arr2->Mat[i]);
        if (arr1->Mat[i] == arr2->Mat[i]) {
            count++;
        }
    }
    float ret = (float)count / ((float)row * (float)col);
    printf("%.2f", ret * 100);
    free(arr1);
    free(arr2);
    arr1 = NULL;
    arr2 = NULL;
    return 0;
}